<extend name="Public/base" />
<block name="body" >
	<div class="main-title">
		<h2>{$product['id']?'编辑':'新增'}商品</h2>
	</div>

    <form action="{:U('Product/writeProduct')}" enctype="application/x-www-form-urlencoded" method="POST"
            class="form-horizontal" name="edit_product"  ng-init='product = {$product}'>
        <div class="form-item">
            <label for="product-spu" class="item-label">商品编号</label>
            <div class="controls">
                <input id="product-spu" type="text" name="spu" class="text input-large" ng-model="product.spu" {$product['id']?'disabled':'ensure-unique="spu"'}  required />
                <span class="error" ng-show="edit_product.spu.$error.required">必填</span>
                <p class="error" ng-show="edit_product.spu.$error.unique">商品编号已存在</p>
            </div>
        </div>
        <div class="form-item">
            <label for="product-name" class="item-label">商品名称</label>
            <div class="controls">
                <input id="product-name" type="text" name="name" class="text input-large" value="{$product.name}" ng-model="product.name" required/>
                <span class="error" ng-show="edit_product.name.$error.required">必填</span>
            </div>
        </div>
        <div class="form-item">
            <label for="product-pinyin" class="item-label">商品拼音</label>
            <div class="controls">
                <input id="product-pinyin" type="text" name="pinyin" class="text input-large" value="{$product.pinyin}" ng-model="product.pinyin" pattern="^[a-zA-z]+$" required/>
                <span class="error" ng-show="edit_product.pinyin.$error.pattern">请输入拼音</span>
                <span class="error" ng-show="edit_product.pinyin.$error.required">必填</span>
            </div>
        </div>
        <div class="form-item">
            <label for="product-classname" class="item-label">商品分类</label>
            <div class="controls">
                <select name="classname" id="classname" class="search-input" style="height: 30px;width:130px">
                    <volist name="data.classList" id="vo">
                        <if condition="($vo.title == $_classname)">
                            <option value="{$vo.title}" selected="selected">{$vo.title}</option>
                            <else/>
                            <option value="{$vo.title}">{$vo.title}</option>
                        </if>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <input type="hidden" name="id" value="{$id}"/>
            <button type="submit" class="btn submit-btn ajax-post" target-form="form-horizontal" ng-disabled="edit_product.$invalid " >确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>
<block name="script">
    <script type="text/javascript" charset="utf-8">
        //导航高亮
        highlight_subnav('{:U('Product/index')}');
    </script>
</block>